<?php
/**
 * UI控件容器类
 *
 * @since 1.1.0
 * @package if
 * @subpackage module.ui
 */
class UIContainer extends IObject {
	private $controls = array();
	private static $instance;
	private $maxOrder = -1;
	private $controlsByOrder = array();
	
	private function __construct() {
		
	}
	
	/**
	 * Enter description here...
	 *
	 * @return UIContainer
	 */
	static function instance() {
		if (!self::$instance) {
			self::$instance = new self;
		}
		return self::$instance;
	}
	
	function add(UIControl $control) {
		$this->controls[$control->id()] = $control;
		$this->controls[$control->option("order")] = $control;
	}
	
	/**
	 * Enter description here...
	 *
	 * @param unknown_type $id
	 * @return UIControl
	 */
	function get($id) {
		return isset($this->controls[$id]) ? $this->controls[$id] : null;
	}
	
	function getByOrder($order) {
		return isset($this->controls[$order]) ? $this->controls[$order] : null;
	}
	
	function controls() {
		return $this->controls;
	}
	
	function maxOrder() {
		return ++ $this->maxOrder;
	}
}

?>